<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core" template="/template.xhtml">

	<ui:define name="css">
		<h:outputStylesheet library="css" name="estilo.css"></h:outputStylesheet>
	</ui:define>
	<ui:define name="title"> Bidman</ui:define>
	<ui:define name="conteudo">

		<h:form prependId="false" id="Fornecedor">
			<p:panel header="Cadastro de Fornecedor"
				style="font-size:22px;margin:auto;text-align: center;">
				<h:panelGrid columns="3" style="margin:auto;font-size:12px;">
					<p:outputLabel value="Nome:"
						style="font-weight: bold;color:#404040" />
					<p:inputText id="nome" value="#{usuarioController.usuario.nome}"
						required="true" requiredMessage="Campo Obrigatório"
						validatorMessage="Somente Letras / Digite seu nome completo">
						<f:validateRegex pattern="([\p{L}\s]+)" for="nome" />
					</p:inputText>
					<p:message for="nome" display="text" id="nomeMessage" />
					<p:outputLabel value="CPF:" style="font-weight: bold;color:#404040" />
					<p:inputMask value="#{usuarioController.usuario.cpf}"
						mask="999.999.999-99" required="true"
						requiredMessage="Campo Obrigatório" id="cpf"
						validator="CPFValidate" />
					<p:message for="cpf" display="text" id="cpfMessage" />

					<p:outputLabel value="RG:" style="font-weight: bold;color:#404040" />
					<p:inputMask value="#{usuarioController.usuario.rg}"
						mask="9.999.999" required="true"
						requiredMessage="Campo Obrigatório" id="rg" />
					<p:message for="rg" display="text" id="rgMessage" />

					<p:outputLabel value="E-mail:"
						style="font-weight: bold;color:#404040" />
					<p:inputText value="#{usuarioController.usuario.email}"
						required="true" requiredMessage="Campo Obrigatório" id="email"
						validatorMessage="Digite um e-mail válido">
						<f:validateRegex
							pattern="(^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$)"
							for="email" />
					</p:inputText>
					<p:message for="email" display="text" id="emailMessage" />

					<p:outputLabel value="Telefone:"
						style="font-weight: bold;color:#404040" />
					<p:inputMask value="#{usuarioController.usuario.telefone}"
						requiredMessage="Campo Obrigatório" id="telefone"
						mask="(99)9999-9999" />
					<p:message for="telefone" display="text" id="telefoneMessage" />
					<p:outputLabel value="Tipo:"
						style="font-weight: bold;color:#404040"
						rendered="#{loginController.usuario.perfil == 1}" />
					<p:selectOneMenu id="tp_usuario" required="true"
						value="#{usuarioController.usuario.perfil}"
						rendered="#{loginController.usuario.perfil == 1}"
						requiredMessage="CampoObrigatório">
						<f:selectItem itemLabel="Administrador" itemValue="1" />
						<f:selectItem itemLabel="Fornecedor" itemValue="2" />
					</p:selectOneMenu>
					<p:message for="tp_usuario" display="text" id="tp_usuarioMessage"
						rendered="#{loginController.usuario.perfil == 1}" />
					<p:outputLabel value="Usuario:"
						style="font-weight: bold;color:#404040" />
					<p:inputText value="#{usuarioController.usuario.usuario}"
						required="true" requiredMessage="Campo Obrigatório" id="user"
						validator="UsernameValidate">
						<f:validateRegex pattern="([\w]+)" for="user" />
					</p:inputText>
					<p:message for="user" display="text" id="userMessage" />
					<p:outputLabel value="Senha:"
						style="font-weight: bold;color:#404040" />
					<p:inputText type="password"
						value="#{usuarioController.usuario.senha}" required="true"
						requiredMessage="Campo Obrigatório" id="pass"
						validatorMessage="Tente uma senha mais complexa">
						<f:validateRegex pattern="(?=^.{6,255}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*" for="pass" />
					</p:inputText>
					<p:message for="pass" display="text" id="passMessage" />
					<p:tooltip for="pass"
						value="Experimente uma senha com os caracteres #$%" />
					<h:panelGroup>
						<p:commandButton action="#{usuarioController.salvarUsuario}"
							value="Salvar" update="Fornecedor" style="width:90px"
							icon="ui-icon-plus" />
						<p:commandButton action="#{usuarioController.cancelar}"
							value="Cancelar" immediate="true" style="width:90px"
							icon="ui-icon-cancel" />
					</h:panelGroup>
				</h:panelGrid>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>


